class Test(object):
    name = 'bzs'
    age = 25

    def __init__(self):
        self.gender = 'male'

    def keys(self):
        return ['name', 'gender']

    def __getitem__(self, item):
        return getattr(self, item)


o = Test()
print(dict(o))
